package com.roamer.audition.server.entity;

import com.roamer.audition.server.entity.base.LogicDeleteBaseEntity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * 公司 Entity
 *
 * @author roamer
 * @version V1.0
 * @date 2019-08-20 22:34
 */
@Entity
@Table(name = "t_company", indexes = {@Index(name = "company_name_index", columnList = "company_name"),
        @Index(name = "address_index", columnList = "address"),
        @Index(name = "linkman_index", columnList = "linkman"),})
@Where(clause = "is_deleted = false")
@NamedEntityGraphs(
        {@NamedEntityGraph(name = "company.all", attributeNodes = {@NamedAttributeNode(value = "auditionRecordList")})})

@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class Company extends LogicDeleteBaseEntity {

    private static final long serialVersionUID = 5562857408134977282L;

    /**
     * 公司名称
     */
    @Column(name = "company_name", nullable = false, length = 50, columnDefinition = "varchar(50) comment '公司名称'")
    private String companyName;

    /**
     * 地点
     */
    @Column(name = "address", nullable = false, columnDefinition = "varchar(255) comment '地址'")
    private String address;

    /**
     * 联系人
     */
    @Column(name = "linkman", length = 50, columnDefinition = "varchar(50) comment '联系人'")
    private String linkman;

    /**
     * 联系方式
     */
    @Column(name = "contact", nullable = false, length = 100, columnDefinition = "varchar(100) comment '联系方式'")
    private String contact;

    /**
     * 面试计划 集合
     */
    @OrderBy("id desc")
    @OneToMany(mappedBy = "company", fetch = FetchType.LAZY)
    @org.hibernate.annotations.ForeignKey(name = "none")
    List<AuditionRecord> auditionRecordList;


}
